﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Xml;

namespace SHomeWorkshop.LunarPresentation.Expressions
{
    public class UnKnow : Expression
    {
        public UnKnow(SubPanel rootPanel, SubPanel parentPanel, Editor editor)
            : base(rootPanel, parentPanel, editor)
        {
            mainButton = new Button();
            mainButton.Background = Brushes.WhiteSmoke;
            mainButton.Foreground = Brushes.DarkGray;
            mainButton.Content = "※未知类型公式※";
            mainButton.Click += new System.Windows.RoutedEventHandler(mainButton_Click);
            this.mainBorder.Child = mainButton;

            this.chineseName = "未知类型";
        }

        void mainButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            e.Handled = true;
            if (this.XmlData == null)
            {
                MessageBox.Show("未找到此公式的后台数据，无法显示相关信息！",
                    Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            XmlAttribute attrType = this.XmlData.GetAttribute("Type");
            if (attrType == null)
            {
                MessageBox.Show("未能在此公式的后台数据中找到类型信息！",
                   Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            MessageBox.Show("此公式类型代码为：" + attrType.Value,
                   Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
        }

        private Button mainButton;

        protected override void BuildChildren()
        {
            base.BuildChildren();
        }

        public override void SetProperty(string propertyName, string value)
        {
            base.SetProperty(propertyName, value);

            //switch (propertyName)
            //{
            //    case "Indent":
            //        {
            //            this.Indent = int.Parse(value);
            //            break;
            //        }
            //}
        }
    }
}
